package com.offcn.file;

import org.csource.common.MyException;
import org.csource.fastdfs.*;

import java.io.IOException;

public class TestFastDfs {
    public static void main(String[] args) throws IOException, MyException {
        //获取全局的配置文件
        ClientGlobal.init("E:\\idear4\\dongyimai-parent\\dongyimai-service\\dongyimai-file-service\\src\\main\\resources\\fdfs_client.conf");
        //1.创建 trackerClient

        TrackerClient trackerClient = new TrackerClient();

        //2.通过trackerClient 创建 trackerserver

        TrackerServer trackerServer = trackerClient.getConnection();

        //3.创建 storageserver   不需要指定，直接指定为null
        StorageServer storageServer = null;
        //4.根据trockerserver 和 storagesever 创建storageclient
        StorageClient storageClient = new StorageClient(trackerServer, storageServer);

        //5.通过storageclient 事项文件上传
        String[] strings = storageClient.upload_file("C:\\Users\\Administrator\\Desktop\\upload\\a406223648bb4cedbab2766a56537099.jpg", "gif", null);
        for (String string : strings){
            System.out.println(string);
        }

    }
}
